package com.sccba.web.controller.yjcz;

import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;

import com.sccba.common.annotation.Log;
import com.sccba.common.core.controller.BaseController;
import com.sccba.common.core.domain.AjaxResult;
import com.sccba.common.core.domain.entity.SysUser;
import com.sccba.common.core.page.TableDataInfo;
import com.sccba.common.enums.BusinessType;
import com.sccba.common.utils.poi.ExcelUtil;
import com.sccba.emtbusiness.service.IYjczEmergencySceneService;
import com.sccba.system.service.ISysUserService;
import org.apache.ibatis.annotations.Param;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.sccba.emtbusiness.domain.YjczEmergencyHandleProcess;
import com.sccba.emtbusiness.service.IYjczEmergencyHandleProcessService;

/**
 * 应急处置操作流程Controller
 * 
 * @author lichh
 * @date 2024-04-18
 */
@RestController
@RequestMapping("/yjcz/emergencyHandleProcess")
public class YjczEmergencyHandleProcessController extends BaseController
{
    @Autowired
    private IYjczEmergencyHandleProcessService yjczEmergencyHandleProcessService;

    @Autowired
    private IYjczEmergencySceneService yjczEmergencySceneService;

    @Autowired
    private ISysUserService sysUserService;

    /**
     * 查询应急处置操作流程列表
     */
    @PreAuthorize("@ss.hasPermi('yjcz:emergencyHandleProcess:fbChannelScene:list')")
    @GetMapping("/list")
    public TableDataInfo list(YjczEmergencyHandleProcess yjczEmergencyHandleProcess)
    {
        startPage();
        List<YjczEmergencyHandleProcess> list = yjczEmergencyHandleProcessService.selectYjczEmergencyHandleProcessList(yjczEmergencyHandleProcess);
        return getDataTable(list);
    }

    /**
     * 导出应急处置操作流程列表
     */
    @PreAuthorize("@ss.hasPermi('yjcz:emergencyHandleProcess:fbChannelScene:export')")
    @Log(title = "应急处置操作流程", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, YjczEmergencyHandleProcess yjczEmergencyHandleProcess)
    {
        List<YjczEmergencyHandleProcess> list = yjczEmergencyHandleProcessService.selectYjczEmergencyHandleProcessList(yjczEmergencyHandleProcess);
        ExcelUtil<YjczEmergencyHandleProcess> util = new ExcelUtil<YjczEmergencyHandleProcess>(YjczEmergencyHandleProcess.class);
        util.exportExcel(response, list, "应急处置操作流程数据");
    }

    /**
     * 获取应急处置操作流程详细信息
     */
    @PreAuthorize("@ss.hasPermi('yjcz:emergencyHandleProcess:fbChannelScene:query')")
    @GetMapping(value = "/{pkId}")
    public AjaxResult getInfo(@PathVariable("pkId") Long pkId)
    {
        return success(yjczEmergencyHandleProcessService.selectYjczEmergencyHandleProcessByPkId(pkId));
    }

    /**
     * 新增应急处置操作流程
     */
    @PreAuthorize("@ss.hasPermi('yjcz:emergencyHandleProcess:fbChannelScene:add')")
    @Log(title = "应急处置操作流程", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody YjczEmergencyHandleProcess yjczEmergencyHandleProcess)
    {
        return toAjax(yjczEmergencyHandleProcessService.insertYjczEmergencyHandleProcess(yjczEmergencyHandleProcess));
    }

    /**
     * 修改应急处置操作流程
     */
    @PreAuthorize("@ss.hasPermi('yjcz:emergencyHandleProcess:fbChannelScene:edit')")
    @Log(title = "应急处置操作流程", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody YjczEmergencyHandleProcess yjczEmergencyHandleProcess)
    {
        return toAjax(yjczEmergencyHandleProcessService.updateYjczEmergencyHandleProcess(yjczEmergencyHandleProcess));
    }

    /**
     * 删除应急处置操作流程
     */
    @PreAuthorize("@ss.hasPermi('yjcz:emergencyHandleProcess:fbChannelScene:remove')")
    @Log(title = "应急处置操作流程", businessType = BusinessType.DELETE)
	@DeleteMapping("/{pkIds}")
    public AjaxResult remove(@PathVariable Long[] pkIds)
    {
        return toAjax(yjczEmergencyHandleProcessService.deleteYjczEmergencyHandleProcessByPkIds(pkIds));
    }


    /**
     * 查询应急场景列表
     */
    @PreAuthorize("@ss.hasPermi('yjcz:emergencyHandleProcess:fbChannelScene:add')")
    @PostMapping("/querySceneList")
    public AjaxResult querySceneList(@RequestBody Map<String, String> params)
    {
        return success(yjczEmergencySceneService.selectSceneNotSelected(params.get("fbId"), params.get("channelId")));
    }


    @PreAuthorize("@ss.hasPermi('yjcz:emergencyHandleProcess:fbChannelScene:add')")
    @GetMapping("/userList")
    public AjaxResult userList(SysUser sysUser)
    {
        return success(sysUserService.selectUserList(sysUser));
    }
}
